package com.codingday.app;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.Typeface;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapView;

import com.google.android.maps.Overlay;

public class OverlayYou extends Overlay{
	
	Context context;
	double latitude;
	double longitude;

	
	/*
	public OverlayYou(Context context){
		new OverlayYou(context, GeoAlarm.getInstance().getService().getLocationManager().getLatitude(),GeoAlarm.getInstance().getService().getLocationManager().getLongitude());
	}
	*/
	
	public OverlayYou(Context context, double latitude, double longitude){
		this.context = context;
		this.latitude = latitude;
		this.longitude = longitude;
	}
	
	@Override
	public void draw(Canvas canvas, MapView mapView, boolean shadow) {
		// TODO Auto-generated method stub
		super.draw(canvas, mapView, shadow);
		
	     Paint paint2 = new Paint();
	     Paint stroke = new Paint();
	     paint2.setARGB(255, 189, 222,0);

	     paint2.setTextAlign(Paint.Align.CENTER);
	     paint2.setTextSize(20);
	     paint2.setTypeface(Typeface.DEFAULT_BOLD);
	     paint2.setStrokeWidth(2);
	     
	     stroke.setARGB(255, 0, 0,0);
	     stroke.setTextAlign(Paint.Align.CENTER);
	     stroke.setTextSize(20);
	     stroke.setTypeface(Typeface.DEFAULT_BOLD);
	     stroke.setStyle(Paint.Style.STROKE);
	     stroke.setStrokeWidth(7);
		
		
	     GeoPoint geoPoint = new GeoPoint((int)(latitude*1E6),(int)(longitude*1E6)); 
	     Point pixPoint = new Point(); 
	     mapView.getProjection().toPixels(geoPoint, pixPoint); 
		
	     Bitmap bmp = BitmapFactory.decodeResource(context.getResources(), R.drawable.you);
	     //canvas.drawBitmap(bmp, pixPoint.x-bmp.getWidth()/2, pixPoint.y-bmp.getHeight()/2, null);   
	     canvas.drawBitmap(bmp, pixPoint.x-bmp.getWidth()/2, pixPoint.y-bmp.getHeight(), null); 
	     
	     canvas.drawText("You", pixPoint.x, pixPoint.y+20, stroke);
	     canvas.drawText("You", pixPoint.x, pixPoint.y+20, paint2);
	     
	}
}
